package com.xxx.shetuan3.dao;

import com.xxx.shetuan3.pojo.User;
import com.xxx.shetuan3.service.UserService;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserDao  {
    @Insert("insert into user" +
            "(account,password,name,role,other_info)" +
            "values(#{account},#{password},#{name},#{role},#{otherInfo})"
    )
    public boolean saveUser(User user);

    @Select("select user_id userId,account,password,name,role,other_info otherInfo" +
            " from user where account = #{account}")
    public User findUserByAccount(String account);

    @Select("select user_id userId,account,password,name,role,other_info otherInfo" +
            " from user where user_id = #{userId}")
    public User findUserByUserId(Integer userId);


    @Insert("update user "+
            "set password = #{password},name=#{name},role=#{role},other_info = #{otherInfo} "+
            "where user_id = #{userId}"
    )
    public boolean updateUser(User user);

    @Delete("delete from user where user_id = #{userId}")
    public boolean deleteUserById(int user_id);
   // public boolean deleteUserByAccount(String account);
}
